/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.uml_generator.manager;

import java.util.Set;

import com.genia.toolbox.basics.exception.BundledException;
import com.genia.toolbox.basics.exception.technical.TechnicalIOException;
import com.genia.toolbox.uml_generator.bean.ModelGeneratorContext;
import com.genia.toolbox.uml_generator.model.AbstractClassModel;
import com.genia.toolbox.uml_generator.model.AbstractDelegatableObject;
import com.genia.toolbox.uml_generator.model.AbstractJavaObject;
import com.genia.toolbox.uml_generator.model.AssociationModel;
import com.genia.toolbox.uml_generator.model.AttributeModel;

/**
 * manager that allows determine properties of model object.
 */
public interface ModelInspector
{

  /**
   * returns wether the object is
   * {@link com.genia.toolbox.persistence.bean.Persistable}.
   * 
   * @param object
   *          the object to inspect
   * @return <code>true</code> if and only if the object is
   *         {@link com.genia.toolbox.persistence.bean.Persistable}
   * @throws BundledException
   *           when an error occurred
   */
  public boolean isPersistable(AbstractDelegatableObject object)
      throws BundledException;



  /**
   * returns wether the object is
   * {@link com.genia.toolbox.persistence.bean.Persistable} while its parent is
   * not.
   * 
   * @param object
   *          the object to inspect
   * @return <code>true</code> if and only if the object is
   *         {@link com.genia.toolbox.persistence.bean.Persistable} and its
   *         parent is not
   * @throws BundledException
   *           when an error occurred
   */
  public boolean isFirstPersistable(AbstractDelegatableObject object)
      throws BundledException;



  /**
   * returns the {@link AttributeModel} corresponding to the identifier of a
   * persistable class.
   * 
   * @param classModel
   *          the object to inspect
   * @return the {@link AttributeModel} corresponding to the identifier of a
   *         persistable class or <code>null</code> if the class is not
   *         persistable, or its parent is already persistable
   * @throws BundledException
   *           when an error occurred
   */
  public AttributeModel getIdentifier(AbstractClassModel classModel)
      throws BundledException;



  /**
   * returns the {@link AbstractClassModel} representing the
   * {@link com.genia.toolbox.persistence.bean.Persistable} interface.
   * 
   * @param context
   *          the generator context
   * @return the {@link AbstractClassModel} representing the
   *         {@link com.genia.toolbox.persistence.bean.Persistable} interface if
   *         it exists, <code>null</code> otherwise
   * @throws BundledException
   *           when an error occurred
   */
  public AbstractClassModel getPersistableModel(ModelGeneratorContext context)
      throws BundledException;



  /**
   * returns the minimum list of object an object must implement.
   * 
   * @param classModel
   *          the {@link AbstractDelegatableObject} to consider
   * @return the minimum list of object an object must implement
   */
  public Set<AbstractClassModel> findMinimumImplementationSet(AbstractDelegatableObject classModel);



  /**
   * returns the {@link AbstractJavaObject} representing the object used for an
   * association.
   * 
   * @param association
   *          the association being inspected
   * @return the {@link AbstractJavaObject} representing the object used for the
   *         association
   * @throws TechnicalIOException
   *           when an I/O error occurred
   */
  public AbstractJavaObject getTypeForAssociation(AssociationModel association)
      throws TechnicalIOException;
}
